# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgname=unicode-character-database
pkgver=15.0.0
pkgrel=1
pkgdesc="Unicode Character Database"
url="https://www.unicode.org/"
arch=(any)
license=(BSD)
makedepends=(lynx)
source=("UCD-$pkgver.zip::https://www.unicode.org/Public/zipped/$pkgver/UCD.zip"
        "Unihan-$pkgver.zip::https://www.unicode.org/Public/zipped/$pkgver/Unihan.zip"
        "unicode-license.html::https://www.unicode.org/license.html")
noextract=({UCD,Unihan}-$pkgver.zip)
sha512sums=('442a99694fccf0d1ff6f6236bec2cff7408eef4d9dba575ba4f5dc45cebf4d2b1b30334ef8a843887a0f410b24e0f79f7f30f06a195659def998875981604a6a'
            'd9cf39adebe83ed0fd8d473cf057b8aa8b2362019d9f7ee7afc041501b1bbbe4d13050350ac40ce4a020cd1d64d52548fe262c3b2893934a032e1de8075e964c'
            'd28bdea752a53463ae19b527c1e3221870cf3292218b3563d9820eb2fe34a5a9a98d622d2b78293779203bcd3f22ec0cd675e7651f79267bc02b35516fb3b0c7')

build() {
  lynx -dump -display_charset=utf-8 unicode-license.html > LICENSE
}

package() {
  local x
  for x in UCD Unihan; do
    install -Dm644 $x-$pkgver.zip "$pkgdir/usr/share/unicode/$x.zip"
    bsdtar -C "$pkgdir/usr/share/unicode" -x --no-same-owner --no-same-permissions -f $x-$pkgver.zip
  done

  # FS#49938: A bunch of compatibility symlinks
  ln -s . "$pkgdir/usr/share/unicode/ucd"
  for x in $pkgname unicode-data unidata; do
    ln -s unicode "$pkgdir/usr/share/$x"
  done

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 LICENSE
}

# vim:set sw=2 sts=-1 et:
